function res = DriveXe129(obj, varargin)
    p=inputParser;
    p.addOptional('amplitude', 3e-3, @(x) x>0.0 && x<1.0);
    p.addParameter('detuning', 0.0, @isnumeric);
    p.addParameter('recordTime', 0, @(x) x>=0);
    p.addParameter('preDrivingTime', 3.0, @(x) x>0);
    p.parse(varargin{:});
    try
        freq0 = obj.Xe129FIDSignal.fft.center;
    catch
        error('Cannot get Central frequency.');
    end
    
    if p.Results.recordTime > 0
        tm = timer('ExecutionMode', 'singleShot', 'StartDelay', p.Results.preDrivingTime);
        tm.TimerFcn = @(myTimerObj, thisEvent) drv129(obj, freq0 + p.Results.detuning, p.Results.amplitude);
        start(tm);
    
        obj.Xe129.unsubscribe_signal();
        obj.Xe129.subscribe_signal(ziDemodTime.R, [2, 1, 1]);
        obj.Xe129.subscribe_signal(ziDemodTime.Theta, [2, 1, 2]);        
        res.signal = obj.Xe129.getDemodSignal(p.Results.recordTime+p.Results.preDrivingTime);
        
        res.amplitude = p.Results.amplitude;
        res.detuning = p.Results.detuning;
        res.timestamp = datetime('now');
        
        delete(tm);
        
        getSession;
        sess.addData('Xe129Driving', res, sprintf('Amplitude%5.3e_Detuning%3.3f_Center%6.4f', p.Results.amplitude, p.Results.detuning, freq0));
    else
        drv129(obj, freq0 + p.Results.detuning, p.Results.amplitude);
        res = [];
    end
    
end

function drv129(obj, freq, amp)
    obj.setNMR('frequency129', freq);
    obj.by129.setAC('frequency', freq, 'amplitude', amp, 'range', 10.0); 
end

